import React,{ useState } from 'react'
import { useEffect } from 'react';

export default function App() {
  let [opacity,setOpacity] = useState(1)

  useEffect(()=>{
    const opacityTimer = setInterval(()=>{
      opacity -= 0.1;
      if(opacity <= 0){
        opacity = 1
      }
      //然后把每次opcity的值赋值给opacity
      setOpacity(opacity)
    },100)

    return () => {
      clearInterval(opacityTimer)
    }
  })


  return (
    <div>
      <h1 style={{opacity}}>111111111</h1>
    </div>
  )
}
